home *** CD-ROM | disk | FTP | other *** search
/ PC Action 1997 January / PCA0197.ISO / demos / ambe / roxy / roxy.dxr / 02750_final import-cast handler...TEST!!.ls < prev    next >
Encoding:
Text File  |  1996-10-28  |  12.3 KB  |  365 lines

  1. on FinalImportAll confirmation
  2.   if the paramCount < 1 then
  3.     alert("Do you REALLY want to import all cast? If so, type 'FinalImportAll REALLY'...")
  4.     exit
  5.   end if
  6.   put "confirmation:"
  7.   put confirmation
  8.   set the colorDepth to 8
  9.   updateStage()
  10.   put "I've set the colordepth to 256 colors..."
  11.   if confirmation <> "REALLY" then
  12.     alert("Do you REALLY want to import all cast? If so, type 'FinalImportAll REALLY'...")
  13.     exit
  14.   end if
  15.   repeat with i = 1 to the number of castMembers
  16.     if the mouseDown then
  17.       exit
  18.     end if
  19.     if the freeBlock < 2000000 then
  20.       saveMovie("BigDog")
  21.       unLoadCast()
  22.     end if
  23.     if the fileName of cast i <> EMPTY then
  24.       if the castType of cast i = #bitmap then
  25.         set myName to the name of cast i
  26.         set myScript to the scriptText of cast i
  27.         set myRegPt to the regPoint of cast i
  28.         set myPurgePriority to the purgePriority of cast i
  29.         set myPalette to the palette of cast i
  30.         puppetPalette(myPalette, 60)
  31.         updateStage()
  32.         importFileInto(cast i, the fileName of cast i)
  33.         set the name of cast i to myName
  34.         set the scriptText of cast i to myScript
  35.         set the regPoint of cast i to myRegPt
  36.         set the purgePriority of cast i to myPurgePriority
  37.         set the palette of cast i to myPalette
  38.         put "Imported PICT cast number " & i & "," && the name of cast i & "," & " sucessfully."
  39.       end if
  40.     end if
  41.     if the fileName of cast i <> EMPTY then
  42.       if the castType of cast i = #sound then
  43.         set myName to the name of cast i
  44.         set myScript to the scriptText of cast i
  45.         set myPurgePriority to the purgePriority of cast i
  46.         importFileInto(cast i, the fileName of cast i)
  47.         set the name of cast i to myName
  48.         set the scriptText of cast i to myScript
  49.         set the purgePriority of cast i to myPurgePriority
  50.         put "Imported Sound cast number " & i & "," && the name of cast i & "," & " sucessfully."
  51.       end if
  52.     end if
  53.     if the fileName of cast i <> EMPTY then
  54.       if the castType of cast i = #movie then
  55.         set myName to the name of cast i
  56.         set myScript to the scriptText of cast i
  57.         set myPurgePriority to the purgePriority of cast i
  58.         importFileInto(cast i, the fileName of cast i)
  59.         set the name of cast i to myName
  60.         set the scriptText of cast i to myScript
  61.         set the purgePriority of cast i to myPurgePriority
  62.         put "Imported Director movie cast number " & i & "," && the name of cast i & "," & " sucessfully."
  63.       end if
  64.     end if
  65.   end repeat
  66.   set date to the short date
  67.   set time to the short time
  68.   set dateTime to date & "," & time
  69.   put "Errors or non-imports on these cast:"
  70.   repeat with i = 1 to the number of castMembers
  71.     if the fileName of cast i <> EMPTY then
  72.       put the name of cast i
  73.     end if
  74.   end repeat
  75. end
  76.  
  77. on replaceFromFolder folderName, newPalNumber
  78.   if not integerp(newPalNumber) then
  79.     alert("Sorry, you've gotta tell me the new palette number in param2..")
  80.     exit
  81.   end if
  82.   if the castType of cast newPalNumber <> #palette then
  83.     alert("Sorry, cast " & newPalNumber & " isn't a palette castmember..")
  84.     exit
  85.   end if
  86.   set the colorDepth to 8
  87.   if the colorDepth <> 8 then
  88.     alert("Sorry, the colordepth needs to be 8-bit for this to work")
  89.     exit
  90.   end if
  91.   set fileList to []
  92.   set tempList to []
  93.   repeat with i = 1 to the maxinteger
  94.     set n to getNthFileNameInFolder(the pathName & folderName & ":", i)
  95.     if n = EMPTY then
  96.       exit repeat
  97.     end if
  98.     append(fileList, n)
  99.     append(tempList, n)
  100.   end repeat
  101.   put "fileList = " & fileList
  102.   put "tempList = " & tempList
  103.   put "fileList = tempList?  " & fileList = tempList
  104.   repeat with currentFile in tempList
  105.     if the freeBlock < 2000000 then
  106.       put "   <i> Hold on a minute, I'm low on space and saving.."
  107.       saveMovie()
  108.       put "    OK, back in action..."
  109.     end if
  110.     set lowestCast to 800
  111.     set highestCast to 2500
  112.     repeat with i = lowestCast to highestCast
  113.       if the name of cast i = currentFile then
  114.         puppetPalette(newPalNumber)
  115.         updateStage()
  116.         set myName to the name of cast i
  117.         set myScript to the scriptText of cast i
  118.         set myRegPt to the regPoint of cast i
  119.         set myPurgePriority to the purgePriority of cast i
  120.         set myPalette to newPalNumber
  121.         set myHeight to the height of cast i
  122.         set myWidth to the width of cast i
  123.         importFileInto(cast i, the pathName & folderName & ":" & the name of cast i)
  124.         set the name of cast i to myName
  125.         set the scriptText of cast i to myScript
  126.         set the regPoint of cast i to myRegPt
  127.         set the purgePriority of cast i to myPurgePriority
  128.         set the palette of cast i to myPalette
  129.         put "Imported cast number " & i & "," && the name of cast i & "," & " sucessfully."
  130.         if (myWidth <> the width of cast i) or (myHeight <> the height of cast i) then
  131.           beep()
  132.           put "<!> NOTE that height or width of cast " & i & " (" & the name of cast i & ") has changed..."
  133.         end if
  134.         deleteAt(fileList, getPos(fileList, currentFile))
  135.         exit repeat
  136.       end if
  137.     end repeat
  138.     if i = (highestCast + 1) then
  139.       put "ΓÇóΓÇóΓÇó <!>  failed to find match for file " & currentFile
  140.     end if
  141.   end repeat
  142.   put "Errors or non-imports on these cast:"
  143.   repeat with i in fileList
  144.     put i
  145.   end repeat
  146. end
  147.  
  148. on importFolder folderName
  149.   set oldDelim to the itemDelimiter
  150.   put "old delimiter was " & oldDelim
  151.   set the itemDelimiter to ":"
  152.   set fileList to []
  153.   set tempList to []
  154.   repeat with i = 1 to the maxinteger
  155.     set n to getNthFileNameInFolder(the pathName & folderName & ":", i)
  156.     if n = EMPTY then
  157.       exit repeat
  158.     end if
  159.     append(fileList, n)
  160.     append(tempList, n)
  161.   end repeat
  162.   put "fileList = " & fileList
  163.   put "tempList = " & tempList
  164.   put "fileList = tempList?  " & fileList = tempList
  165.   repeat with currentFile in tempList
  166.     if the freeBlock < 2000000 then
  167.       saveMovie("BigDog")
  168.       put "Wow, I just had to save that one (as 'BigDog')..."
  169.     end if
  170.     put currentFile
  171.     repeat with i = 1239 to 1340
  172.       if the last item in the fileName of cast i = currentFile then
  173.         puppetPalette(the palette of cast i)
  174.         updateStage()
  175.         set myName to the name of cast i
  176.         set myScript to the scriptText of cast i
  177.         set myRegPt to the regPoint of cast i
  178.         set myPurgePriority to the purgePriority of cast i
  179.         set myPalette to the palette of cast i
  180.         erase(member i)
  181.         importFileInto(cast i, the fileName of cast i)
  182.         set the name of cast i to myName
  183.         set the scriptText of cast i to myScript
  184.         set the regPoint of cast i to myRegPt
  185.         set the purgePriority of cast i to myPurgePriority
  186.         set the palette of cast i to myPalette
  187.         put "Imported cast number " & i & "," && the name of cast i & "," & " sucessfully."
  188.         deleteAt(fileList, getPos(fileList, currentFile))
  189.         exit repeat
  190.       end if
  191.     end repeat
  192.     if i = 1340 then
  193.       put "failed to find match for file " & currentFile
  194.       next repeat
  195.     end if
  196.     put "found match for " & currentFile
  197.   end repeat
  198.   set the itemDelimiter to oldDelim
  199.   put "Errors or non-imports on these cast:"
  200.   repeat with i in fileList
  201.     put i
  202.   end repeat
  203. end
  204.  
  205. on findAssignedPalette whichPalette
  206.   if stringp(whichPalette) then
  207.     set whichPalette to the number of member whichPalette
  208.   end if
  209.   put EMPTY
  210.   put "The following castmembers use palette " & whichPalette & " (" & the name of cast whichPalette & ")"
  211.   repeat with i = 1 to the number of castMembers
  212.     if the castType of cast i = #bitmap then
  213.       if the palette of cast i = whichPalette then
  214.         put the name of cast i & " (number " & i & ")"
  215.       end if
  216.     end if
  217.   end repeat
  218.   put EMPTY
  219. end
  220.  
  221. on reportPalettes
  222.   put EMPTY
  223.   put "ΓÇóΓÇóΓÇó PALETTE REPORT ΓÇóΓÇóΓÇó"
  224.   set howManyPalettes to 0
  225.   repeat with i = 1 to the number of castMembers
  226.     if the castType of cast i = #palette then
  227.       set howManyPalettes to howManyPalettes + 1
  228.       put the name of cast i & " (cast " & i & ")"
  229.       set loyalCast to 0
  230.       repeat with j = 1 to the number of castMembers
  231.         if the castType of cast j = #bitmap then
  232.           if the palette of cast j = i then
  233.             set loyalCast to loyalCast + 1
  234.           end if
  235.         end if
  236.       end repeat
  237.       put "  used by " & loyalCast & " bitmap castmembers"
  238.     end if
  239.   end repeat
  240.   put "ΓÇóΓÇóΓÇó TOTAL: " & howManyPalettes & " custom palettes in cast ΓÇóΓÇóΓÇó"
  241. end
  242.  
  243. on changePalsFromFolder folderName, testFlag
  244.   set firstDomainBitmap to 550
  245.   set lastDomainBitmap to 2300
  246.   set temporaryCast to findEmpty(cast 1000)
  247.   put "temporaryCast = " & temporaryCast
  248.   if the colorDepth <> 8 then
  249.     alert("Hey, this really only works in 8-bit color..")
  250.     exit
  251.   end if
  252.   set oldDelim to the itemDelimiter
  253.   put "old delimiter was " & oldDelim
  254.   set the itemDelimiter to ":"
  255.   set fileList to []
  256.   set tempList to []
  257.   repeat with i = 1 to the maxinteger
  258.     set n to getNthFileNameInFolder(the pathName & folderName & ":", i)
  259.     if n = EMPTY then
  260.       exit repeat
  261.     end if
  262.     append(fileList, n)
  263.     append(tempList, n)
  264.   end repeat
  265.   put "Searching folder '" & the pathName & folderName & ":'"
  266.   put "fileList = " & fileList
  267.   if testFlag = #test then
  268.     exit
  269.   end if
  270.   if testFlag <> #really then
  271.     alert("ΓÇóΓÇó Don't forget second param '#really' ΓÇóΓÇó")
  272.     exit
  273.   end if
  274.   repeat with currentFile in tempList
  275.     put currentFile
  276.     repeat with i = firstDomainBitmap to lastDomainBitmap
  277.       if (the last item in the fileName of cast i = currentFile) and (the castType of cast i = #bitmap) then
  278.         importFileInto(cast temporaryCast, the pathName & folderName & ":" & currentFile)
  279.         set newPaletteNumber to the palette of cast temporaryCast
  280.         put "new palette = " & the name of cast newPaletteNumber & " (cast " & newPaletteNumber & ")"
  281.         set the palette of cast i to newPaletteNumber
  282.         puppetPalette(the palette of cast i)
  283.         updateStage()
  284.         put "Re-paletted cast " & i & "," && the name of cast i & "," & " sucessfully."
  285.         deleteAt(fileList, getPos(fileList, currentFile))
  286.         exit repeat
  287.       end if
  288.     end repeat
  289.     if i = lastDomainBitmap then
  290.       put "failed to find match for file " & currentFile
  291.     end if
  292.   end repeat
  293.   duplicate(cast findEmpty(cast 1000), temporaryCast)
  294.   set the itemDelimiter to oldDelim
  295.   put "No match found (or non-bitmap?) for these files:"
  296.   repeat with i in fileList
  297.     put i
  298.   end repeat
  299. end
  300.  
  301. on lookForLinkedFiles
  302.   repeat with i = 1 to the number of castMembers
  303.     if the fileName of cast i <> EMPTY then
  304.       put i & ":" & the name of cast i
  305.     end if
  306.   end repeat
  307. end
  308.  
  309. on shiftPalettes palFolder, confirmation
  310.   if not stringp(palFolder) then
  311.     put "Sorry, you must specify a new-palettes folder in param 2."
  312.     exit
  313.   end if
  314.   if param(3) <> #really then
  315.     put "Sorry, you must confirm this operation with #really in param 3."
  316.     exit
  317.   end if
  318.   set the colorDepth to 8
  319.   if the colorDepth <> 8 then
  320.     put "Sorry, couldn't switch the colordepth to 8... I'm bailing."
  321.     exit
  322.   end if
  323.   set lsNewPalettes to []
  324.   repeat with i = 1 to the maxinteger
  325.     set n to getNthFileNameInFolder(the pathName & palFolder & ":", i)
  326.     if n = EMPTY then
  327.       exit repeat
  328.     end if
  329.     append(lsNewPalettes, n)
  330.   end repeat
  331.   put lsNewPalettes
  332.   repeat with theFile in lsNewPalettes
  333.     importFileInto(cast findEmpty(cast 4000), theFile)
  334.   end repeat
  335.   set oldPalettes to [:]
  336.   sort(oldPalettes)
  337.   repeat with cNum = 1 to 3999
  338.     if the castType of cast cNum = #palette then
  339.       set cName to the name of cast cNum
  340.       if not voidp(getaProp(oldPalettes, cName)) then
  341.         alert("Duplicate palette in cast:  '" & cName & "'")
  342.       end if
  343.       addProp(oldPalettes, cName, cNum)
  344.     end if
  345.   end repeat
  346.   put "oldPalettes = " & oldPalettes
  347.   set lsImagesByPalette to [#None: []]
  348.   repeat with palNumber in oldPalettes
  349.     addProp(lsImagesByPalette, palNumber, [])
  350.   end repeat
  351.   put "lsImagesByPalette = " & lsImagesByPalette
  352.   repeat with cNum = 1 to 3999
  353.     if the castType of cast cNum <> #bitmap then
  354.       next repeat
  355.     end if
  356.     if the depth of cast cNum <> 8 then
  357.       set myCohort to getProp(lsImagesByPalette, #None)
  358.     else
  359.       set myCohort to getProp(lsImagesByPalette, the palette of cast cNum)
  360.     end if
  361.     append(myCohort, cNum)
  362.   end repeat
  363.   put "lsImagesByPalette = " & lsImagesByPalette
  364. end
  365.